var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var ResKeeper = require("AA_ResKeeper");
var CommonUtils = require("AA_CommonUtils");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_BoxAward = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.touchNode = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {
    this.touchNode.width = cc.winSize.width;
    this.touchNode.height = cc.winSize.height;
    this.touchNode.active = false;
  };
  _creator.prototype.onDisable = function () {
    this.touchNode.active = false;
  };
  _creator.prototype.hideTouchNode = function () {
    this.node.active = false;
    this.touchNode.active = false;
  };
  _creator.prototype.showAward = function (e, t, o, n) {
    undefined === n && (n = 1);
    this.node.x = e.x;
    this.node.active = true;
    this.node.scale = 0;
    cc.tween(this.node).to(.25, {
      scale: 1
    }, {
      easing: "backOut"
    }).start();
    this.touchNode.active = true;
    this.setAwardNode(t, o, n);
  };
  _creator.prototype.getNowJiangLi = function (e, t, o) {
    var n = null;
    if (1 == o) {
      "1" == t && (n = e.awardbox1);
      "2" == t && (n = e.awardbox2);
      "3" == t && (n = e.awardbox3);
    }
    if (2 == o) {
      "1" == t && (n = e.tiaozhanbox1);
      "2" == t && (n = e.tiaozhanbox2);
      "3" == t && (n = e.tiaozhanbox3);
      "4" == t && (n = e.tiaozhanbox4);
    }
    return n;
  };
  _creator.prototype.setAwardNode = function (e, t, o) {
    var n = this;
    var i = this.getNowJiangLi(e, t, o);
    var a = ["ui/tu/powerIcon", "ui/tu/goldIcon", "ui/tu/diamondIcon", "quality/suipian_1", "quality/suipian_2", "quality/suipian_3"];
    var r = function (e, t) {
      return __awaiter(n, undefined, undefined, function () {
        var o;
        var n;
        var i;
        var r;
        var c;
        var l;
        return __generator(this, function (s) {
          switch (s.label) {
            case 0:
              o = t.getChildByName("img").getComponent(cc.Sprite);
              n = t.getChildByName("awardlb").getComponent(cc.Label);
              i = "";
              r = 0;
              switch (e[0]) {
                case 1:
                  i = "res/" + a[1];
                  r = e[1];
                  break;
                case 2:
                  i = "res/" + a[2];
                  r = e[1];
                  break;
                case 3:
                  i = "res/" + a[0];
                  r = e[1];
                  break;
                case 5:
                  c = e[1];
                  r = e[2];
                  1 == c && (i = "res/" + a[3]);
                  2 == c && (i = "res/" + a[4]);
                  3 == c && (i = "res/" + a[5]);
              }
              return [4, this._loadRes(BundleConfig.BundleNames.Common, "common/" + i, cc.SpriteFrame)];
            case 1:
              l = s.sent();
              o.spriteFrame = l;
              CommonUtils.default.LimitSpriteMaxSize(o, 60);
              n.string = "+" + r;
              return [2];
          }
        });
      });
    };
    var l = this.node.children[0].children;
    l.forEach(function (e) {
      e.active = false;
    });
    for (var p = 0; p < i.length; p++) {
      var h = i[p];
      var f = l[p];
      if (!f) {
        f = cc.instantiate(l[0]);
        this.node.children[0].addChild(f);
      }
      f.active = true;
      r(h, f);
    }
    this.scheduleOnce(function () {
      n.node.width = n.node.children[0].width;
      var e = n.node.x;
      var t = n.node.x - n.node.width / 2;
      var o = n.node.x + n.node.width / 2;
      t < -cc.winSize.width / 2 && (n.node.x = -(cc.winSize.width / 2 - n.node.width / 2));
      o > cc.winSize.width / 2 && (n.node.x = cc.winSize.width / 2 - n.node.width / 2);
      n.node.children[1].x = e - n.node.x;
    });
  };
  __decorate([_property(cc.Node)], _creator.prototype, "touchNode", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_BoxAward;